﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Doo_JetDAL;
using DoodJetView.Core.Reservation;

namespace DoodJetView.VuesPartielles
{
    /// <summary>
    /// Logique d'interaction pour ReservationCreation.xaml
    /// </summary>
    public partial class ReservationCreation : UserControl
    {
        public ReservationCreation(MainWindow Main)
        {
            InitializeComponent();
            
            MainWindows = Main;
            LoadDataForForm();
            UpdateListClient();
        }

        private void UpdateListClient()
        {
            using(DataEntities db = new DataEntities()){
                List<client> liste = db.client.OrderBy(o=>o.nomClient).ToList();
                ListClient.Items.Clear();

                foreach (client item in liste)
                {

                    ListClient.Items.Add(new {Id = item.id_client, Nom = item.nomClient });
                }
            }
        }
        private void LoadDataForForm(){
            //Chargement des Activités 
            using (DataEntities db = new DataEntities())
            {
                List<TypeEquipement> equipements =  db.TypeEquipement.ToList();
                foreach (TypeEquipement t in equipements)
                {
                    var Poco = new TypeEquipement_Poco { ID = (int)t.id_TypeEquipement, Nom = t.libelle };
                    this.listBox_Activites.Items.Add(Poco);
                }
            
            }
        }
        public MainWindow MainWindows { get; set; }

        /// <summary>
        /// Déclenche le rafrachissement de la vue!
        /// </summary>
        private void ActualiseResultat() 
        {
            this.ViewResultat = new DynamicGridResultat(GridResultat);
            ViewResultat.Render();
        }
        private void button2_Click(object sender, RoutedEventArgs e)
        {
            PartialDayOfActivities prt = new PartialDayOfActivities("test");
           // this.TabsPos.Items.Clear();
            var item = this.MainWindows.ContentGrid.Children[0] as ReservationCreation;
            //item.DayByDay.Children.Add(prt);
        }

        internal DynamicGridResultat ViewResultat { get; set; }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            ActualiseResultat();
        }
    }
}
